package com.daify.threadlearn.chapter01.order04;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author daify
 * @date 2019-06-05
 */
public class VisualComponent {

    private final List<String> key1 = new CopyOnWriteArrayList<String>();

    private final List<String> key2 = new CopyOnWriteArrayList<String>();

    public void addKey1(String str) {
        if (key2.size() > key1.size()) {
            key1.add(str);
        }
    }

    public void addKey2(String str) {
        key2.add(str);
    }

    public void removeKey1(String str) {
        key1.remove(str);
    }

    public void removeKey2(String str) {
        key2.remove(str);
    }


    public synchronized void addKey1Test(String str) {
        if (key1.contains(str)) {
            key1.add(str);
        }

    }
}
